package com.heima.behavior.controller.v1;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.api.behavior.ApUnLikesBehaviorControllerApi;
import com.heima.behavior.service.ApUnLikesBehaviorService;
import com.heima.model.behavior.dtos.UnLikesBehaviorDto;
import com.heima.model.behavior.pojos.ApUnlikesBehavior;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @作者 itcast
 * @创建日期 2020/10/8 15:19
 **/
@RestController
@RequestMapping("/api/v1/unlike_behavior")
public class ApUnLikesBehaviorController implements ApUnLikesBehaviorControllerApi {
    @Autowired
    ApUnLikesBehaviorService apUnLikesBehaviorService;
    @PostMapping
    @Override
    public ResponseResult unlikeBehavior(@RequestBody UnLikesBehaviorDto dto) {
        return apUnLikesBehaviorService.unlikeBehavior(dto);
    }
    @GetMapping("/one")
    @Override
    public ApUnlikesBehavior findUnLikeByArticleIdAndEntryId(@RequestParam("articleId") Long articleId,
                                                             @RequestParam("entryId") Integer entryId) {
        return apUnLikesBehaviorService.getOne(
                Wrappers.<ApUnlikesBehavior>lambdaQuery()
                        .eq(ApUnlikesBehavior::getArticleId, articleId)
                        .eq(ApUnlikesBehavior::getEntryId, entryId)
        );
    }
}
